<script setup>
import { cateListService } from '@/api/article' // 引入api
import { ref, onMounted } from 'vue' // 引入ref

defineProps({
  // 获取父组件传递的参数
  modelValue: {
    type: [Number, String]
  }
})

const emit = defineEmits(['update:modelValue']) // 获取父组件传递的参数
const channelList = ref([]) // 创建ref
// 获取频道列表
const getChannelList = async () => {
  const res = await cateListService()

  channelList.value = res.data
}
// 获取频道列表
onMounted(() => {
  getChannelList()
})
</script>
<template>
  <el-select
    :modelValue="modelValue"
    @update:modelValue="emit('update:modelValue', $event)"
  >
    <el-option
      v-for="channel in channelList"
      :key="channel.id"
      :label="channel.cate_name"
      :value="channel.id"
    ></el-option>
  </el-select>
</template>
